import React from 'react';
import { Card, WingBlank, WhiteSpace } from 'antd-mobile';
import propsType from 'prop-types';
import { withRouter } from 'react-router-dom';
@withRouter
class UserCard extends React.Component{
	static propsType = {
		userList:propsType.array.isRequired
	}
	handleItemClick(v){
		this.props.history.push(`/chat/${v._id}`);
	}
	render(){
		return (
			<div>
				<WingBlank>
					<WhiteSpace />
					{this.props.userList.map(v => (
						<div key={v._id}>
							<WhiteSpace />
							<Card 
								key={v._id}
								onClick={()=>this.handleItemClick(v)}
							>
							<Card.Header
								title={v.user}
								thumb={require(`../img/${v.avatar}.jpg`)}
								thumbStyle={{width:'30px'}}
								extra={v.title}
							/>
							<Card.Body>
								{v.type === 'boss' ? <div>公司：{v.company}</div> : null}
								{v.desc.split('\n').map(d => (
									<div key={d}>{d}</div>
								))}
								{v.type === 'boss' ? <div>薪资：{v.money}</div> : null}
							</Card.Body>
							</Card>
						</div>
					))}
				</WingBlank>
			</div>
		)
	}
}

export default UserCard